<!DOCTYPE html>
<html lang="zh" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>目录 Menu</title>
    <link rel="stylesheet" href="../static/css/style.css" th:href="@{/css/style.css}"/>
    <link rel="stylesheet" href="../static/css/editormd.css" th:href="@{/css/editormd.css}"/>
    <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon"/>
</head>
<body>
<div id="layout">
    <button onclick="as()">点击</button>
    <div id="menuHtml">
    </div>
    <textarea id="tx"></textarea>
    <div id="menu">
    </div>

</div>
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script src="../static/js/editormd.js" th:src="@{/js/editormd.js}"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var testEditor;
    var md_file = /*[[@{/md/menu.md}]]*/ '../static/md/menu.md';
    var lib_path = /*[[@{/lib/}]]*/ '../static/lib/';
    $(function () {
        $.get(md_file, function (md) {
            testEditor = editormd("menu", {
                width: "90%",
                height: 740,
                path: lib_path,
                markdown: md,
                saveHTMLToTextarea: true,    // 保存 HTML 到 Textarea
                searchReplace: true,
                htmlDecode: "style,script,iframe|on*",            // 开启 HTML 标签解析，为了安全性，默认不开启
                flowChart: true,             // 开启流程图支持，默认关闭
                sequenceDiagram: true
            });
        });

    });
    function as() {
        $("#tx").val($(".editormd-markdown-textarea").val());
        //转换开始,第一个参数是上面的div的id
       editormd.markdownToHTML("menuHtml", {
           htmlDecode: "style,script,iframe", //可以过滤标签解码
           emoji: true,
           taskList:true,
           tex: true,               // 默认不解析
           flowChart:true,         // 默认不解析
           sequenceDiagram:true,  // 默认不解析
       });
        console.log(editormd.getHTML())
        console.log(editormd.getTextareaSavedHTML())
        $("#menuHtml").html(editormd.getPreviewedHTML());
    }
    /*]]>*/
</script>
</body>
</html>